package com.huangpeng.algorithm.robRedPacket;

/**
 * @Author hp
 * @Title 多线程模拟用户抢红包
 * @Package
 * @Date 2022/1/29 16:58
 * @Description
 * @Version 1.0
 */
public class UserThread1 implements Runnable{
    private RedPacket1 redPacket1;

    public UserThread1(RedPacket1 redPacket1) {
        this.redPacket1 = redPacket1;
    }

    @Override
    public void run() {
        double money = redPacket1.getRandomMoney();
        if(money == 0) {
            System.out.println(Thread.currentThread().getName() + "不好意思，您手慢了！");
        }else {
            System.out.println(Thread.currentThread().getName() + "抢到 " + money + "元");
        }
    }
}
